from bs4 import BeautifulSoup

with open('4.html','r',encoding='utf8') as f:
    data =f.read()


soup = BeautifulSoup(data)

# print(soup.prettify())
scripts = soup.find_all('script')
# count = 0
# for s in scripts:
#     print("count-->",count)
#     try:
#
#         print(str(s.contents[0]).index("eval"))
#         print(str(s.contents[0]).index("const video"))
#         print(str(s.contents[0])[str(s.contents[0]).index("eval"):str(s.contents[0]).index("const video")])
#         # count +=1
#     except:
#         pass
#     count += 1
s = scripts[7]
data = str(s.contents[0])[str(s.contents[0]).index("eval"):str(s.contents[0]).index("const video")]
print(data[5:-2])
import execjs,os,requests
#
# with open("1.js", 'r', encoding='utf-8') as f:
#     data = f.read()
os.environ["EXECJS_RUNTIME"] = "Node"
print(execjs.get().name)
# 执行js脚本，获取返回值 url
m3u8_url = execjs.eval(data) #Node.js (V8)

print(m3u8_url)
